package com.hcy.rabbitmanagerapi.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hcy.orderclient.OrderBaseClient;
import com.hcy.ordermodel.dto.request.ManagerOrderRequestDTO;
import com.hcy.ordermodel.dto.request.ManagerPayOrderRequestDTO;
import com.hcy.ordermodel.dto.request.SimplePayOrderResponseDTO;
import com.hcy.ordermodel.dto.response.SimpleOrderResponseDTO;
import com.hcy.rabbitbasicmodel.dto.MyPage;
import com.hcy.rabbitbasicmodel.model.ResponseData;
import com.hcy.rabbitbasicmodel.model.ReturnResult;
import com.hcy.rabbitbasicutils.utils.CheckUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author huchenying
 * @Description
 * @Date 2022/5/13
 **/
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {


    @Autowired
    OrderBaseClient orderBaseClient;
    /**
     * @Author huchenying
     * @Description  查询服务单
     * @Date 2022/5/13 21:59
     **/
    @PostMapping("/getServerOrderList")
    public ReturnResult getServerOrderList(@Validated @RequestBody ManagerOrderRequestDTO requestDTO){
        ResponseData<MyPage<SimpleOrderResponseDTO>> serverOrderList = orderBaseClient.getServerOrderList(requestDTO);
        if(serverOrderList.getCode().noSuccess()){
            return ReturnResult.fail("获取失败");
        }
        return ReturnResult.success(serverOrderList.getData());
    }

    /**
     * @Author huchenying
     * @Description 查询支付单
     * @Date 2022/5/13 21:59
     **/
    @PostMapping("/getPayOrderList")
    public ReturnResult getPayOrderList(@Validated @RequestBody ManagerPayOrderRequestDTO requestDTO){
        ResponseData<MyPage<SimplePayOrderResponseDTO>> payOrderList = orderBaseClient.getPayOrderList(requestDTO);
        if(payOrderList.getCode().noSuccess()){
            return ReturnResult.fail("获取失败");
        }
        return ReturnResult.success(payOrderList.getData());
    }
}
